/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2021-11-27     Algo       the first version
 */

#ifndef APPLICATIONS_KEY_H_
#define APPLICATIONS_KEY_H_

/** key check interval, unit ms */
#define KEY_CHECK_INTERVAL      (10)
/** key long press times , unit ms */
#define KEY_LONG_PRESS_TIME     (400)
/** key short press times */
#define KEY_SHORT_PRESS_TIME    (40)
/** key long press times */
#define KEY_DOUBLE_PRESS_TIME   (40)


/* key status */
typedef enum _key_state
{
    KEY_STATE_DOWN = 0x0,
    KEY_STATE_UP,
    KEY_STATE_MAX,
}key_state_t;

/** Only Use User Key S2 and S3 */
typedef enum _key_code {
    KEY_CODE_S2 = 0,
    KEY_CODE_S3,
    KEY_CODE_MAX,
}key_code_t;

typedef enum _key_event {
    KEY_EVT_DOWN = 0x0,
    KEY_EVT_UP,
    KEY_EVT_HOLD,
    KEY_EVT_DOUBLE,
    KEY_EVT_MAX,
}key_event_t;

typedef rt_int32_t (*key_callback_t)(key_code_t code, key_event_t event);

int key_init(key_callback_t callback);

#endif /* APPLICATIONS_KEY_H_ */
